package arsmodelller.factories;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import arsmodeller.model.Link;
import arsmodeller.model.ObjectProcessingDiagram;
import arsmodeller.part.LinkEditPart;
import arsmodeller.part.ObjectEditPart;
import arsmodeller.part.ObjectProcessDiagramEditPart;
import arsmodeller.part.ProcessEditPart;

public class MEditPartFactory implements EditPartFactory {

	@Override
	public EditPart createEditPart(EditPart context, Object model) {
		EditPart part = null;

		if (model instanceof ObjectProcessingDiagram) {
			part = new ObjectProcessDiagramEditPart();
		} else if (model instanceof Object) {
			part = new ObjectEditPart();
		} else if (model instanceof Process) {
			part = new ProcessEditPart();
		} else if (model instanceof Link) {
			part = new LinkEditPart();
		}

		if (part != null) {
			part.setModel(model);
		}

		return part;
	}
}
